<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>栏目添加</title>
    <meta name="keywords" content="后台产品添加">
    <meta name="description" content="后台产品添加">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__ADMIN__css/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN__css/font-awesome.min.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__ADMIN__css/animate.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/skin/default/layer.css" rel="stylesheet">
    <link href="__ADMIN__css/style.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/switchery/switchery.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加栏目</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" id="formadd" name="formadd" class="form-horizontal" action="{:U('Columns/save')}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">栏目名称：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="title" name="title" value="{$resultedit.coltitle}">
                            </div>
                            <input type="hidden" name="id" value="{$resultedit.id}">
                            <input type="hidden" name="editpid" value="{$resultedit.pid}">
                            <input type="hidden" name="pid" value="{$resultadd.pid}">
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">英文名称：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="entitle" name="entitle" value="{$resultedit.entitle}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">类型：</label>
                            <div class="col-sm-10">
                               <select class="form-control" name="type" id="type">
                                    <option value="">====请选择类型====</option>
                                    <option value="1" <if condition="$resultedit['type'] eq 1">selected</if>>文章</option>
                                    <option value="2" <if condition="$resultedit['type'] eq 2">selected</if>>产品</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO标题：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="seo_title" name="seo_title" value="{$resultedit.seo_title}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO关键词：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="seo_keywords" name="seo_keywords" value="{$resultedit.seo_keywords}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO描述：</label>
                            <div class="col-sm-10">
                            <textarea name="seo_description" id="seo_description" rows="8" cols="160">{$resultedit.seo_description}</textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否前台菜单：</label>
                            <div class="col-sm-10">
                                <input type="radio" name="is_nav" id="is_nav" value="1" <if condition="$resultedit['is_nav'] eq 1">checked</if>>前台
                                <input type="radio" name="is_nav" id="is_nav" value="2" <if condition="$resultedit['is_nav'] eq 2">checked</if>>后台
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="sort" name="sort" value="{$resultedit.sort}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-10">
                                <if condition="$resultedit['id'] neq ''">
                                <input type="checkbox" name="status" id="status" value="1" class="js-switch" 
                                <if condition="$resultedit['status'] eq 1">checked</if>>
                                <else/>
                                <input type="checkbox" name="status" id="status" value="1" class="js-switch" checked>
                                </if>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <a class="btn btn-white" href="javascript:history.go(-1)">取消</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ADMIN__js/plugins/validate/messages_zh.min.js"></script>
<script src="__ADMIN__js/plugins/switchery/switchery.js"></script>
<script src="__ADMIN__js/plugins/layer/layer.js"></script>
<script src="__ADMIN__js/comment.js"></script>
<script>
    var elem = document.querySelector('.js-switch');
    var init = new Switchery(elem,{ size: 'small', jackColor: '#9decff' });  
    $(function(){
        $('#formadd').validate({ 
            rules:{
                title:"required", 
                entitle:"required",
                type:"required",
                is_nav:"required"
            },
            messages:{
                title:'栏目名称不能为空!',
                entitle:'英文名称不能为空！',
                type:'请选择类型！',
                is_nav:'请选择是否显示菜单！'
            },
            //提交成功后执行
            submitHandler:function(form){
                var objNames = $(form).serializeArray();
                var dataName = new Object();
                $.each(objNames,function(key,val){
                    dataName[val.name] = val.value;
                });
                $.ajax({
                    url:$(form).attr('action'),//地址是通过form 的action
                    type:'post',
                    dataType:'json',
                    data:dataName,//传的对象
                    success:function(data){
                        if(data.status < 1){
                            comment.error(data.mess);
                        }else{
                            comment.success(data.mess,"{:U('Columns/glist')}");
                        }
                    }
                });

            }
        });
    });
</script>
</body>
</html>